/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package newpeer;

import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.JMenuItem;
import javax.swing.JOptionPane;

/**
 *
 * @author Manuel
 */
public class ListenerMenuPeer implements ActionListener{
    private Peer padre;

    ListenerMenuPeer(Peer aThis) {
        this.padre=aThis;
    }

    
    public void actionPerformed(ActionEvent e) {
        JOptionPane.showMessageDialog(null, "Fuente");
        JMenuItem source = (JMenuItem)(e.getSource());
        JOptionPane.showMessageDialog(null, "Fuente");
        String comando=source.getActionCommand();
        if(comando.equals(Peer.SALIR)){
            int res=JOptionPane.showConfirmDialog(padre, "¿Desea salir de la aplicación?", "Salir", JOptionPane.YES_NO_CANCEL_OPTION,JOptionPane.QUESTION_MESSAGE);
            if(res==JOptionPane.YES_OPTION){
                padre.dispose();
            }
        }
        else if(comando.equals(Peer.CONFIGURACION)){
            padre.abrirDialogoConfiguracionPeer();
        }
    }


}
